﻿CREATE PROCEDURE [dbo].[ETL_SP_SearchVDtSourceTotalCount]
	@DtSerId uniqueidentifier,
	@HasTask char
AS
if @HasTask = 'Y' or @HasTask = 'y'
begin 
	SELECT COUNT(DS.Id)
	from ETL_DtSource as DS
	WHERE DS.DtSerId = @DtSerId
				and DS.Id in (select TASK.DtSourceId from ETL_Task as TASK)
end
else if @HasTask = 'N' or @HasTask = 'n'
begin
	SELECT COUNT(DS.Id)
	from ETL_DtSource as DS
	WHERE DS.DtSerId = @DtSerId
				and DS.Id not in (select TASK.DtSourceId from ETL_Task as TASK)
end
else
begin
	SELECT COUNT(DS.Id)
	from ETL_DtSource as DS
	WHERE DS.DtSerId = @DtSerId
end
RETURN 0